package com.example.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.service.CategoryService;
import com.example.service.CommentService;
import com.example.service.PostService;
import com.example.service.UserService;
import com.example.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.ServletRequestUtils;

import javax.servlet.http.HttpServletRequest;

public class BaseController {

    @Autowired
    HttpServletRequest req;

    @Autowired
    RedisUtil redisUtil;

    @Autowired
    PostService postService;

    @Autowired
    CategoryService categoryService;

    @Autowired
    CommentService commentService;

    @Autowired
    UserService userService;

    public Page getPage() {
        int pn =  ServletRequestUtils.getIntParameter(req, "pn", 1);
        int size =  ServletRequestUtils.getIntParameter(req, "size", 10);
        Page page = new Page(pn, size);
        return page;
    }

}
